#ifndef SBTMATH_H_INCLUDED
#define SBTMATH_H_INCLUDED

#include "SbtPrerequisites.h"
#include <cmath>

namespace Sbt
{

namespace MathConstant
{
    const float Epsilon = 1e-8f;
    const float Pi = 3.1415926f;
    const float Half_Pi = MathConstant::Pi / 2.0f;
    const float Two_Pi  = MathConstant::Pi * 2.0f;
    const float Rad2Deg = 180.0f / MathConstant::Pi;
    const float Deg2Rad = MathConstant::Pi / 180.0f;
}

inline const float Degree(const float degVal)
{
    return degVal * MathConstant::Deg2Rad;
}

inline const float Radian(const float radVal)
{
    return radVal;
}

namespace Math
{

    inline float sqrt(const float rhs)
    {
        return float(std::sqrt(rhs));
    }

    inline float square(const float rhs)
    {
        return float(rhs*rhs);
    }

    inline float pow(const float base, const float exponent)
    {
        return float(std::pow(base,exponent));
    }

    inline float floor(const float rhs)
    {
        return float(std::floor(rhs));
    }

    inline float ceil(const float rhs)
    {
        return float(std::ceil(rhs));
    }

    inline float abs(const float rhs)
    {
        return float(std::abs(rhs));
    }

    inline float radiansToDegrees(const float rad)
    {
        return rad*MathConstant::Rad2Deg;
    }

    inline float degreesToRadians(const float deg)
    {
        return deg*MathConstant::Deg2Rad;
    }

    inline float sign(const float fval)
    {
        if (fval>0.0f)  return 1.0f;
        if (fval<0.0f)  return -1.0f;
        return 0.0f;
    }

    inline bool floatEquals(const float f1, const float f2, const float tolerance)
    {
        return ( abs(f1-f2) < tolerance );
    }

    inline float sin(const float radVal)
    {
        return std::sin(radVal);
    }

    inline float cos(const float radVal)
    {
        return std::cos(radVal);
    }

    inline float tan(const float radVal)
    {
        return std::tan(radVal);
    }

    inline float asin(const float fval)
    {
        return std::asin(fval);
    }

    inline float acos(const float fval)
    {
        return std::acos(fval);
    }

    inline float atan(const float fval)
    {
        return std::atan(fval);
    }

} // namespace Math

} // namespace Sbt

#endif // SBTMATH_H_INCLUDED